/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "permissao", catalog = "carlossa03", schema = "")
@NamedQueries({@NamedQuery(name = "Permissao.findAll", query = "SELECT p FROM Permissao p"), @NamedQuery(name = "Permissao.findByPermissaoId", query = "SELECT p FROM Permissao p WHERE p.permissaoId = :permissaoId"), @NamedQuery(name = "Permissao.findByPagina", query = "SELECT p FROM Permissao p WHERE p.pagina = :pagina")})
public class Permissao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "permissao_id")
    private Integer permissaoId;
    @Basic(optional = false)
    @Column(name = "pagina")
    private String pagina;
    @Lob
    @Column(name = "descricao")
    private String descricao;
    @JoinTable(name = "tipo_usuario_permissao", joinColumns = {@JoinColumn(name = "permissao_id", referencedColumnName = "permissao_id")}, inverseJoinColumns = {@JoinColumn(name = "tipo_usuario_id", referencedColumnName = "tipo_usuario_id")})
    @ManyToMany(fetch = FetchType.EAGER)
    private List<TipoUsuario> tipoUsuarioCollection;

    public Permissao() {
    }

    public Permissao(Integer permissaoId) {
        this.permissaoId = permissaoId;
    }

    public Permissao(Integer permissaoId, String pagina) {
        this.permissaoId = permissaoId;
        this.pagina = pagina;
    }

    public Integer getPermissaoId() {
        return permissaoId;
    }

    public void setPermissaoId(Integer permissaoId) {
        this.permissaoId = permissaoId;
    }

    public String getPagina() {
        return pagina;
    }

    public void setPagina(String pagina) {
        this.pagina = pagina;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public List<TipoUsuario> getTipoUsuarioCollection() {
        return tipoUsuarioCollection;
    }

    public void setTipoUsuarioCollection(List<TipoUsuario> tipoUsuarioCollection) {
        this.tipoUsuarioCollection = tipoUsuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (permissaoId != null ? permissaoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Permissao)) {
            return false;
        }
        Permissao other = (Permissao) object;
        if ((this.permissaoId == null && other.permissaoId != null) || (this.permissaoId != null && !this.permissaoId.equals(other.permissaoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getPagina();
    }

}
